<?php

require_once dirname(__FILE__).'/../class/functions.php';
require_once dirname(__FILE__).'/../class/user.class.php';

$a = session_id();if(empty($a)) session_start();

if( !isset($_SESSION['logat']) )
    $_SESSION['logat']="NU";

$logat = is_logat();

?>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <link rel="icon" href="favicon.jpg" type="image/gif" sizes="16x16" /> 
        <link rel="stylesheet" type="text/css" href="../style/style.css" />
        <title>Panou Administriv</title>
    </head>
<body>
   <?
   header_out(1); 
   //footer();
        ?>
        <div id="content">
            <div id="content_inside">
                    <div id="content_inside_sidebar">
                        <ul>
                            <li><a href ="../index.php"> Home</a><br /></li>
                            <li><a href ="admin.php"> Panou Principal</a><br /></li>
                            <li><a href ="p_news.php"> Noutati</a><br /></li>  
                            <li><a href ="p_rezervari.php"> Rezervari</a><br /></li>
                            <li><a href ="p_downloads.php"> Downloads</a><br /></li>                   
                                           
                         </ul>
                                 
                    </div>
            <div id="content_inside_main">
<?  
if($logat == 0)
    die("Nu v-ati logat");
else
{
    if( $_SESSION['logat'] == "admin" )
    {
        echo "sunteti admin";     
        $user = new user_func($_SESSION["id"],$_SESSION["user"],$_SESSION["pass"],0);
      
        ?>
        <form action="admin.php?actiune=cauta" method=post>
        <select name="campul"  >
            <option value=""></option>
            <?
            $sql_select_utiliz="Select ID, username from utilizatori";
            $result = $class_db->q($sql_select_utiliz);
            while($row = mysql_fetch_array($result))
                echo "<option value=$row[0]>$row[1]</option>"
            ?>
            </select>
            <a href="#" class="grey-button pcb"><span><input type="Submit" value="Afiseaza informatii"></input></span></a> <br/> <br/>  
            </form>
        <?

        if(isset($_GET["actiune"]))
            if(strcmp($_GET["actiune"],"cauta")==0)
            {
                $sql_afis_inform = "SELECT a.username,a.parola,a.grup,a.activ,b.Nume, b.Prenume, b.Facultate, b.An, b.Specialitatea, c.telefon FROM utilizatori AS a INNER JOIN detalii_utilizatori AS b ON a.ID=b.ID INNER JOIN carte_telefon AS c ON a.ID=c.user_id Where a.ID=".$_POST["campul"]."";
                $result = $class_db->q($sql_afis_inform);
                $row = mysql_fetch_array($result);
                echo "Username: ".$row["username"]." <br/>";
                echo "Parola: ".$row["parola"]." <br/>";
                if($row["grup"]==1)
                    echo "Grupul: user <br/>";
                else
                    echo "Grupul: admin <br/>";
                
                if($row["activ"]==1)
                    echo "Cont activ <br/>";
                else
                    echo "Cont inactiv <br/>";
                
                
                echo "Numele: $row[4] <br/>";
                echo "Prenumele: $row[5] <br/>";
                echo "Facultatea: $row[6] <br/>";
                echo "Anul: $row[7] <br/>";
                echo "Specialitatea: $row[8] <br/>";
                echo "Telefon: $row[9] <br/>";
                
                echo "<br/>Alegeti campul pe care vreti sa il modificati: <br/>"; 
                $_SESSION["id"]=$_POST["campul"];          
                echo $user->select_tag("./../modifica_un_camp.php");
                
                echo "Modificati drepturi:<br/>";
                
                ?>
                <form action="modifica_drepturi.php" method="post">
                    Starea: <br/>
                    <pre>
                    <input type = "radio" name="activ" value="1">Activ <br/>
                    <input type = "radio" name="activ" value="0">Inactiv <br/>
                    </pre>
                    Grupul:<br/>
                    <pre>
                    <input type = "radio" name="grup" value="0">Admin <br/>
                    <input type = "radio" name="grup" value="1">User <br/>
                    </pre>
                    <a href="#" class="grey-button pcb"><span><input type="Submit" value="Modifica"></input></span></a>
                </form>
                <?
               
                
                
                        
                
            }      
            
            
            
    }
    else
        die("Nu aveti acces pe aceasta pagina");

    
}

?>
                <? footer(1); ?>
</body>


</html>